const mysql = require('mysql');
//链接服务器
const con = mysql.createConnection({
    port: '3306',
    host: 'localhost',
    user: 'root',
    password: '521369',
    database: 'data2'
})
con.connect();
function query(sql) {
    return new Promise((resolve, reject) => {
        con.query(sql, (err, data) => {
            if (err) {
                reject(err)
            } else {
                resolve(data)
            }
        })
    })
}
module.exports = query;